﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:controls="clr-namespace:SilverlightDebateJetPack.Controls"
	xmlns:local="clr-namespace:SilverlightDebateJetPack"
	xmlns:SilverlightDebateViewModel="clr-namespace:SilverlightDebateViewModel;assembly=SilverlightDebateViewModel"
	 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
	xmlns:SilverlightDebateViewModel_Classes="clr-namespace:SilverlightDebateViewModel.Classes;assembly=SilverlightDebateViewModel" 
	xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
	mc:Ignorable="d"
	x:Class="SilverlightDebateJetPack.Statements"
	d:DesignWidth="640" d:DesignHeight="480" Width="670" Height="470">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../Assets/CoreStyles.xaml"/>
				<ResourceDictionary Source="../Assets/SDKStyles.xaml"/>
				<ResourceDictionary Source="../Assets/Styles.xaml"/>
				<ResourceDictionary Source="../Assets/ToolkitStyles.xaml"/>
				<ResourceDictionary Source="/SilverlightDebateJetPack;component/Assets/SDKStyles.xaml"/>
			</ResourceDictionary.MergedDictionaries>

 	<DataTemplate x:Key="cboCategoriesDataTemplate">
			<StackPanel>
				<sdk:Label Content="{Binding Title}"/>
			</StackPanel>
		</DataTemplate>
	</ResourceDictionary>
	</UserControl.Resources>

	<UserControl.DataContext>
		<SilverlightDebateViewModel:StatementsViewModel/>
	</UserControl.DataContext>

    <Grid>
    	<i:Interaction.Triggers>
    		<ei:DataTrigger Binding="{Binding AutoLoadStatements}" Value="True">
    			<i:InvokeCommandAction x:Name="AutoLoadStatements" Command="{Binding LoadStatementsCommand}"/>
    		</ei:DataTrigger>
    		<i:EventTrigger>
    			<i:InvokeCommandAction x:Name="LoadCategories" Command="{Binding LoadCategoriesCommand}"/>
    		</i:EventTrigger>
    	</i:Interaction.Triggers>

      <controls:TiledBackground SourceUri="/SilverlightDebateJetPack;component/Images/backgroundtexture.png" />
      <Image Source="/SilverlightDebateJetPack;component/Images/backgroundshadow.png" Stretch="Fill" />
	<Grid x:Name="LayoutRoot">
		<Border BorderThickness="1" Height="44" VerticalAlignment="Top" Background="{StaticResource ControlOuterHighlightBrush}" BorderBrush="{StaticResource ControlBackgroundAltBrush}"/>
	</Grid>
    	<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,7,0,0">    		
    		<TextBlock Style="{StaticResource Heading2}" TextWrapping="Wrap" Text="Category" VerticalAlignment="Center" Foreground="{StaticResource ColorAccentHighlightBrush}"/>    		
    		<ComboBox x:Name="comboBox" VerticalAlignment="Center" ItemsSource="{Binding CategoryList}" ItemTemplate="{StaticResource cboCategoriesDataTemplate}" SelectedValue="{Binding SelectedCategory, Mode=TwoWay}" Margin="8,0,0,0" Width="116" Height="25"/>
    		<TextBox x:Name="textBox" TextWrapping="Wrap" VerticalAlignment="Center" Margin="13,0,0,0" Width="203" Text="{Binding SearchString, Mode=TwoWay}"/>
    		<Button Content="Search" VerticalAlignment="Center" Command="{Binding LoadStatementsCommand}" Margin="12,0,0,0" Height="25"/>
    	</StackPanel>
    	<Grid Margin="11,53,18,23">
    		<Grid.RowDefinitions>
    			<RowDefinition/>
    			<RowDefinition Height="Auto" MinHeight="28"/>
    		</Grid.RowDefinitions>
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition/>
    		</Grid.ColumnDefinitions>
    	</Grid>
    	<sdk:DataGrid Margin="8,53,8,40" AutoGenerateColumns="False" ItemsSource="{Binding StatementList}">
    		<sdk:DataGrid.Columns>
    			<sdk:DataGridTextColumn Binding="{Binding CategoryTitle}" Header="CategoryTitle"/>
    			<sdk:DataGridTextColumn Binding="{Binding Title}" Header="Title"/>
    			<sdk:DataGridTextColumn Binding="{Binding CreatedBy}" Header="CreatedBy"/>
    			<sdk:DataGridTextColumn Binding="{Binding StatementContent}" Header="StatementContent"/>
    			<sdk:DataGridTextColumn Binding="{Binding AgreeCount}" Header="AgreeCount"/>
    			<sdk:DataGridTextColumn Binding="{Binding DisagreeCount}" Header="DisagreeCount"/>
    		</sdk:DataGrid.Columns>
    	</sdk:DataGrid>
    	<sdk:DataPager x:Name="dataPager" HorizontalAlignment="Left" Source="{Binding StatementPagedCollection}" Margin="8,0,0,8" VerticalAlignment="Bottom" PageSize="8" d:LayoutOverrides="GridBox">
    		<i:Interaction.Triggers>
    			<i:EventTrigger EventName="PageIndexChanged">
    				<i:InvokeCommandAction Command="{Binding SetRecordsByPagerCommand}" CommandParameter="{Binding PageIndex, ElementName=dataPager, Mode=TwoWay}"/>
    			</i:EventTrigger>
    			<ei:PropertyChangedTrigger Binding="{Binding PageSize, ElementName=dataPager}">
    				<i:InvokeCommandAction Command="{Binding SetStatementPerPageCommand}" CommandParameter="{Binding PageSize, ElementName=dataPager}"/>
    			</ei:PropertyChangedTrigger>
    			<i:EventTrigger>
    				<i:InvokeCommandAction Command="{Binding SetStatementPerPageCommand}" CommandParameter="{Binding PageSize, ElementName=dataPager}"/>
    			</i:EventTrigger>
    		</i:Interaction.Triggers>
    	</sdk:DataPager>
    	<ProgressBar Height="10" Template="{StaticResource ProgressBarTemplate}" Width="100" IsIndeterminate="{Binding Searching, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,0,10,22" VerticalAlignment="Bottom"/>
	</Grid>
</UserControl>
